package main

import "fmt"

func main() {
	fmt.Println(hammingWeight(7))
}

func hammingWeight(n int) int {
	v := 0
	for n > 0 {
		if n&1 > 0 {
			v++
		}

		n = n >> 1
	}

	return v
}
